cmake_minimum_required(VERSION 3.0)
project(PatchMatchStereoProject)

# 设置编译器标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native")

# 查找并包含 OpenCV
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
    message("OPENMP FOUND")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
                        
add_executable(pms 
        ./PatchMatchStereo/main.cpp
        ./PatchMatchStereo/pms_propagation.cpp
        ./PatchMatchStereo/PatchMatchStereo.cpp
        ./PatchMatchStereo/pms_util.cpp)


if(OPENMP_FOUND)
    target_compile_options(pms PRIVATE -ffast-math)
    target_link_libraries(pms PRIVATE OpenMP::OpenMP_CXX ${OpenCV_LIBS})
else()
    target_compile_options(pms PRIVATE -ffast-math)
    target_link_libraries(pms PRIVATE ${OpenCV_LIBS})
endif()

